package com.lapelife.backend.controller;

import com.lapelife.backend.common.ResponseResult;
import com.lapelife.backend.model.domain.SysUser;
import com.lapelife.backend.service.LoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


@RestController
@Api(tags = "登录注册控制器")
public class LoginController {
    private LoginService loginService;

    @Autowired
    public void setLoginService(LoginService loginService) {
        this.loginService = loginService;
    }

    @ApiOperation(value = "用户登录")
    @PostMapping("/user/login")
    public ResponseResult<Map<String,String>> login(@RequestBody SysUser user) {
        return loginService.login(user);
    }

    @ApiOperation("用户注册")
    @PostMapping("/user/register")
    public ResponseResult<Map<String,String>> register(@RequestBody SysUser user) {
        return loginService.register(user);
    }

    @ApiOperation("用户退出")
    @GetMapping("/user/logout")
    public ResponseResult<String> logout() {
        return loginService.logout();
    }

    // @ApiImplicitParams({
    //         @ApiImplicitParam(name = "pageNum", value = "页码",
    //                 required = true, type = "Integer"),
    //         @ApiImplicitParam(name = "pageSize", value = "每页条数",
    //                 required = true, type = "Integer"),
    // })
    // @ApiOperation(value = "分页查询用户信息")
    // @GetMapping(value = "page/{pageNum}/{pageSize}")
    // public String findByPage(@PathVariable Integer pageNum,
    //                          @PathVariable Integer pageSize) {
    //     return "OK";
    // }
}
